package com.rgs.base.tasks.task;

import cn.hutool.core.util.IdUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rgs.base.core.system.AsyncTaskStatusEnum;
import com.rgs.base.core.system.AsyncTaskTypeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.annotation.Nullable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Ren Gaoshuai
 * @ClassName AsyncTaskRunnableBO
 * 统一任务模型
 * @date 2022-03-08 15:45
 **/
@Data
@NoArgsConstructor
public class AsyncTaskRunnableBO {

    /**
     * 主键
     */
    private String id;
    /**
     * 所属组织
     */
    private String organizeId;
    /**
     * 任务说明
     */
    private String taskExplain;
    /**
     * 任务类型
     */
    private Integer type;
    /**
     * 任务状态
     */
    private Integer status;
    /**
     * zip
     */
    private String fileName;
    private String fileUrl;
    /**
     * 任务异常信息
     */
    private String errMassage;
    /**
     * 任务时间
     */
    private LocalDateTime createTime;
    @JsonIgnore
    private List<Object> plusParameter;


    public AsyncTaskRunnableBO(
            @Nullable String organizeId,
            AsyncTaskTypeEnum asyncTaskTypeEnum,
            List<Object> plusParameter) {
        this.id = IdUtil.fastSimpleUUID();
        this.organizeId = organizeId;
        this.taskExplain = asyncTaskTypeEnum.getTaskName();
        this.status = AsyncTaskStatusEnum.SUCCEED.getCode();
        this.type = asyncTaskTypeEnum.getCode();
        this.createTime = LocalDateTime.now();
        this.plusParameter = plusParameter;
    }
}
